/*
 *                    COPYRIGHT NOTICE
 *
 *           This code is copyright protected by Freedom Inc.
 *
 *              2001-2012 All Rights Are Reserved
 */
package com.freedom.oldsong.system;

import com.freedom.oldsong.system.dto.PaginationResult;

/**
 * @author steven.wang
 *
 */
public abstract class ListBaseAction extends BaseAction {

	protected PaginationResult pageResult=new PaginationResult();
	
	/**
	 * @name initPagination
	 *    
	 * void     
	 * @throws 
	*/
	protected void initPagination(){
		String totalCount =getRequest().getParameter("totalCount");
		String currentPage =getRequest().getParameter("currentPage");
		String pageCount =getRequest().getParameter("pageCount");
		String pageSize =getRequest().getParameter("pageSize");
		String count =getRequest().getParameter("count");
		String sort =getRequest().getParameter("sort");

		setTotalCount(totalCount);
		setCurrentPage(currentPage);
		setPageCount(pageCount);
		setPageSize(pageSize);
		setCount(count);
		setSort(sort);
	}
	
	/**
	 * @name setSort
	 *
	 * @param sort    
	 * void     
	 * @throws 
	*/
	public void setSort(String sort){
		if(sort!=null && !"".equals(sort)){
			pageResult.setSort(sort);
		}
	}
	
	/**
	 * @name setCount
	 *
	 * @param count    
	 * void     
	 * @throws 
	*/
	public void setCount(String count){
		if(count!=null && !"".equals(count)){
			pageResult.setCount(Integer.valueOf(count));
		}
	}
	
	/**
	 * @name setPageSize
	 *
	 * @param pageSize    
	 * void     
	 * @throws 
	*/
	public void setPageSize(String pageSize){
		if(pageSize!=null && !"".equals(pageSize)){
			pageResult.setPageSize(Integer.valueOf(pageSize));
		}
	}
	
	/**
	 * @name setPageCount
	 *
	 * @param pageCount    
	 * void     
	 * @throws 
	*/
	public void setPageCount(String pageCount){
		if(pageCount!=null && !"".equals(pageCount)){
			pageResult.setPageCount(Integer.valueOf(pageCount));
		}
	}
	
	/**
	 * @name setTotalCount
	 *
	 * @param totalCount    
	 * void     
	 * @throws 
	*/
	public void setTotalCount(String totalCount){
		if(totalCount!=null && !"".equals(totalCount)){
			pageResult.setTotalCount(Integer.valueOf(totalCount));
		}
	}
	
	/**
	 * @name setCurrentPage
	 *
	 * @param currentPage    
	 * void     
	 * @throws 
	*/
	public void setCurrentPage(String currentPage){
		if(currentPage!=null && !"".equals(currentPage)){
			pageResult.setCurrentPage(Integer.valueOf(currentPage));
		}
	}
	
	public PaginationResult getPageResult() {
		return pageResult;
	}

	public void setPageResult(PaginationResult pageResult) {
		this.pageResult = pageResult;
	}

	public String getTotalCount() {
		return String.valueOf(pageResult.getTotalCount());
	}

	public String getCurrentPage() {
		return String.valueOf(pageResult.getCurrentPage());
	}

	public String getPageCount() {
		return String.valueOf(pageResult.getPageCount());
	}

	public String getPageSize() {
		return String.valueOf(pageResult.getPageSize());
	}

	public String getCount() {
		return String.valueOf(pageResult.getCount());
	}

	public String getSort() {
		return String.valueOf(pageResult.getSort());
	}
	
}
